const getters = {
	openId: state => state['user'].openId,
	identity: state => state['user'].identity,
	lifeCircleCurrentTabbar: state => state['life-circle'].lifeCircleCurrentTabbar,
	recruitCurrentTabbar: state => state['recruit'].recruitCurrentTabbar,
	homeCurrentTabbar: state => state['home-tab-bar'].homeCurrentTabbar,
	myTimInfo: state => state['tim'].myTimInfo,
	userTimProfile: state => state['tim'].userTimProfile,
	isSdkReady: state => state['tim'].isSdkReady,
	groupList: state => state['tim'].groupList,
	allConversation: state => state['tim'].allConversation,
	currentConversationID: state => state['tim'].currentConversationID,
	memberList: state => state['tim'].currentGroupMemberList,
	groupProfile: state => state['tim'].currentConversation.groupProfile,
	isIphoneX: state => state['tim'].systemInfo && state['tim'].systemInfo.model.indexOf('iPhone X') > -1,
	timTotalUnreadCount: state => {
		const result = state['tim'].allConversation.reduce((count, {
			unreadCount
		}) => count + unreadCount, 0)
		if (result === 0) {
			uni.removeTabBarBadge({
				index: 0
			})
		} else {
			uni.setTabBarBadge({
				index: 0,
				text: result > 99 ? '99+' : String(result)
			})
		}
		return result
	},
	currentConversation: state => state['tim'].currentConversation,
	currentMessageList: state => {
		return state['tim'].currentMessageList
	},
	toAccount: state => {
		if (state['tim'].currentConversationID.indexOf('C2C') === 0) {
			return state['tim'].currentConversationID.substring(3)
		} else if (state['tim'].currentConversationID.indexOf('GROUP') === 0) {
			return state['tim'].currentConversationID.substring(5)
		}
	},
	// 当前聊天对话的Type
	currentConversationType: state => {
		if (state['tim'].currentConversationID.indexOf('C2C') === 0) {
			return 'C2C'
		}
		if (state['tim'].currentConversationID.indexOf('GROUP') === 0) {
			return 'GROUP'
		}
		return ''
	},
}

export default getters
